Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pt): add finetune_head to argcheck #3967

Merged
merged 3 commits into from
Jul 12, 2024

Conversation

iProzd
Copy link
Collaborator

@iProzd iProzd commented Jul 11, 2024

Add finetune_head to argcheck.

Summary by CodeRabbit

  • New Features

    • Introduced a new finetune_head argument for specifying the fitting net during multi-task fine-tuning, with optional random initialization if not set.
  • Bug Fixes

    • Improved handling for specific conditions by automatically removing the "finetune_head" key from the configuration.
  • Tests

    • Updated multitask training and finetuning tests to include new configuration manipulations.
    • Removed the _comment field from test configuration files to ensure cleaner test setups.

Copy link
Contributor

coderabbitai bot commented Jul 11, 2024

Walkthrough

Walkthrough

Recent changes enhance the fine-tuning mechanism within the deepmd package, particularly focusing on the get_finetune_rules and model_args functions. This includes handling specific configurations, adjusting test methodologies, and introducing the finetune_head argument to better control fine-tuning processes. These updates aim to refine the argument checking process, improve configuration management for tests, and provide more flexibility in multi-task fine-tuning.

Changes

Files/Modules Change Summary
deepmd/pt/utils/finetune.py Modified get_finetune_rules to remove "finetune_head" key from model_config under specific conditions.
source/tests/pt/model/water/multitask.json Removed the _comment field under loss_dict for "model_1".
source/tests/pt/test_multitask.py Imported normalize and update_deepmd_input functions and altered configurations within test methods.
deepmd/utils/argcheck.py Added finetune_head argument to model_args for multi-task fine-tuning configuration.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TestMultitask
    participant FineTuneUtils
    participant ArgCheckUtils

    User->>TestMultitask: Initiate multi-task fine-tuning
    TestMultitask->>ArgCheckUtils: Normalize and update config
    ArgCheckUtils-->>TestMultitask: Return updated config
    TestMultitask->>FineTuneUtils: Call get_finetune_rules with config
    FineTuneUtils-->>TestMultitask: Return fine-tune rules
    TestMultitask->>User: Provide fine-tune rules and results

    Note right of FineTuneUtils: Fine-tune head key handling
Loading

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d562b44 and f6026b7.

Files selected for processing (1)
  • deepmd/utils/argcheck.py (2 hunks)
Additional comments not posted (2)
deepmd/utils/argcheck.py (2)

1636-1641: Ensure consistency in the finetune_head argument documentation.

The documentation for the finetune_head argument is clear and consistent with the rest of the file.

Verify that the documentation for finetune_head is consistent across the codebase.

Verification successful

The documentation for the finetune_head argument is consistent across the codebase.

  • The finetune_head argument is thoroughly documented in deepmd/pt/utils/finetune.py and deepmd/utils/argcheck.py.
  • The behavior and use cases of the argument are clearly explained.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the documentation for `finetune_head` is consistent across the codebase.

# Test: Search for the `finetune_head` documentation. Expect: Consistent documentation.
rg --type python -A 5 $'finetune_head'

Length of output: 68


Script:

#!/bin/bash
# Description: Verify the documentation for `finetune_head` is consistent across the codebase.

# Test: Search for the `finetune_head` documentation in all Python files. Expect: Consistent documentation.
rg --glob '*.py' -A 5 'finetune_head'

Length of output: 7737


1536-1539: Approve the addition of finetune_head argument.

The addition of the finetune_head argument is well-documented and logically integrated.

Verify that all uses of model_args correctly handle the new finetune_head argument.

Verification successful

Verified the usage of model_args function with the new finetune_head argument.

The finetune_head argument is documented and integrated correctly within the model_args function. It is used across multiple files, including test files, without any issues.

  • The argument is correctly added and documented in deepmd/utils/argcheck.py.
  • The usages in source/tests/consistent/model/test_frozen.py and source/tests/consistent/model/test_ener.py do not show any misuse or issues with the finetune_head argument.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `model_args` to ensure it correctly handles the new `finetune_head` argument.

# Test: Search for the function usage. Expect: Correct handling of the `finetune_head` argument.
rg --type python -A 5 $'model_args'

Length of output: 65


Script:

#!/bin/bash
# Description: Verify the usage of `model_args` to ensure it correctly handles the new `finetune_head` argument.

# Test: Search for the function usage. Expect: Correct handling of the `finetune_head` argument.
rg --lang py -A 5 $'model_args'

Length of output: 439


Script:

#!/bin/bash
# Description: Verify the usage of `model_args` to ensure it correctly handles the new `finetune_head` argument.

# Test: Search for the function usage. Expect: Correct handling of the `finetune_head` argument.
rg --type py -A 5 $'model_args'

Length of output: 7633


Script:

#!/bin/bash
# Description: Extract relevant code around each instance of `model_args` to verify the handling of the `finetune_head` argument.

# Extract 10 lines of context around each instance of `model_args`.
rg --type py -C 10 $'model_args'

Length of output: 18647


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Jul 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.83%. Comparing base (bd02ccc) to head (f6026b7).
Report is 108 commits behind head on devel.

Additional details and impacted files
@@           Coverage Diff           @@
##            devel    #3967   +/-   ##
=======================================
  Coverage   82.82%   82.83%           
=======================================
  Files         520      522    +2     
  Lines       50869    50867    -2     
  Branches     3020     3015    -5     
=======================================
+ Hits        42134    42135    +1     
+ Misses       7798     7797    -1     
+ Partials      937      935    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@njzjz
Copy link
Member

njzjz commented Jul 11, 2024

Why isn't this option in the argcheck?

@iProzd
Copy link
Collaborator Author

iProzd commented Jul 11, 2024

Why isn't this option in the argcheck?

This option works only to get finetune rules before argcheck, see https://github.com/deepmodeling/deepmd-kit/blob/devel/deepmd/pt/entrypoints/main.py#L253 . After this, the option is useless.

We can deleted it from the model definition or keep a placeholder in argcheck, which one do we prefer? @njzjz @wanghan-iapcm

@njzjz
Copy link
Member

njzjz commented Jul 11, 2024

We use argcheck to generate the documentation, so all user-defined arguments should be in the argcheck, i.e. in the automatically generated documentation.

@iProzd iProzd changed the title fix(pt): pop finetune_head before argcheck fix(pt): add finetune_head to argcheck Jul 12, 2024
@iProzd iProzd requested a review from njzjz July 12, 2024 08:37
@iProzd iProzd added this pull request to the merge queue Jul 12, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 12, 2024
@iProzd iProzd added this pull request to the merge queue Jul 12, 2024
Merged via the queue into deepmodeling:devel with commit 37bee25 Jul 12, 2024
60 checks passed
@iProzd iProzd deleted the fix_finetune_head branch July 12, 2024 11:41
mtaillefumier pushed a commit to mtaillefumier/deepmd-kit that referenced this pull request Sep 18, 2024
Add `finetune_head`  to argcheck.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced a new `finetune_head` argument for specifying the fitting
net during multi-task fine-tuning, with optional random initialization
if not set.
  
- **Bug Fixes**
- Improved handling for specific conditions by automatically removing
the "finetune_head" key from the configuration.

- **Tests**
- Updated multitask training and finetuning tests to include new
configuration manipulations.
- Removed the `_comment` field from test configuration files to ensure
cleaner test setups.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants